package com.lsk.mps.backend.controller;

import com.lsk.mps.backend.aspect.annotation.JsonReturn;
import com.lsk.mps.backend.model.Message;
import com.lsk.mps.backend.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/manager")
public class ManagerController {
    @Autowired
    private MessageService messageService;

    @JsonReturn
    @PostMapping("/message/publish")
    public Object messagePublish(String content, String title, String type, String needConfirm) {
        messageService.publishMessage(title, content, type, "yes".equals(needConfirm));
        return "Success";
    }

    @JsonReturn
    @GetMapping("/message/notConfirmed")
    public Object messageNotConfirmed(Integer targetID) {
        return messageService.notConfirmedUsers(targetID);
    }

    @JsonReturn
    @GetMapping("/message/confirms")
    public Object messageConfirms(Integer targetID, Integer page) {
        return messageService.queryMessageConfirms(targetID, page);
    }

    @JsonReturn
    @GetMapping("/message/confirmPages")
    public Object messageConfirmPages(Integer targetID) {
        return messageService.messageConfirmsPages(targetID);
    }

}
